/**
 * Created with Vim7.3 ubuntu12.04
 * @fileOverview : 
 * @author : Lyle <lylechen2014@gmial.com>
 * @since : 2014-11-25 13:16:21
 * @filename : app.js
 * @version : 
 * @description : 
 */

define(function(require, exports, module) {
    "use strict";
    require('angular-route'); 
    require('angular-lazyload');
  
    console.log('init app...' + (new Date().getTime()));

    var app = angular.module('app', ['angular-lazyload', 'ngRoute']);
    //配置期
    app.config(['$routeProvider', function($routeProvider) {    
        $routeProvider
          .when('/test/a', {
            controller: 'testACtrl',
            controllerUrl: 'modules/module1/testACtrl.js',
            templateUrl: 'modules/module1/testA.tpl.html'
          })
          .when('/test/b/:id', {
            controller: 'testBCtrl',
            controllerUrl: 'modules/module2/testBCtrl.js',
            templateUrl: 'modules/module2/testB.tpl.html'
          })
          .when('/main', {
            controller: function($scope, $routeParams, $location){
              $scope.str = new Date()
              //console.log($routeParams,$location)
            },
            template: '<div>{{str}}</div>'
          })
          .otherwise({
            redirectTo: '/main'
          });
        }
    ]);

    //运行期
    app.run(['$lazyload', function($lazyload){
        $lazyload.init(app);
        app.register = $lazyload.register;
    }]);

    module.exports = app;
});
